package com.momo.mal.manga.overall;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import net.momo.mal.R;
import com.momo.mal.anime.adapter.AnimeListAdapter;
import com.momo.mal.anime.view.AnimeView;
import com.momo.mal.database.MalDatabaseAdapter;
import com.momo.mal.entity.Anime;
import com.momo.mal.entity.Manga;
import com.momo.mal.manga.adapter.MangaListAdapter;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class MangaTabOnHold extends Fragment {
	private ListView listView;
	private String mContent = "???";

	private static final String KEY_CONTENT = "MangaTabOnHold:Content";

	public static MangaTabOnHold newInstance() {
		MangaTabOnHold fragment = new MangaTabOnHold();

		return fragment;
	}

	// @Override
	// public void onPause() {
	// super.onPause();
	// }
	//
	// @Override
	// public void onResume() {
	// super.onResume();
	// }

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		if ((savedInstanceState != null)
				&& savedInstanceState.containsKey(KEY_CONTENT)) {
			mContent = savedInstanceState.getString(KEY_CONTENT);
		}
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.anime_overall_tab, null);

		List<Manga> mangas = new ArrayList<Manga>();
		mangas.addAll(getMangaComplete());

		MangaListAdapter adapter = new MangaListAdapter(getActivity(), mangas);
		listView = (ListView) view.findViewById(R.id.list_anime);
		listView.setAdapter(adapter);

		return view;
	}

	private List<Manga> getMangaComplete() {
		List<Manga> mangas = new ArrayList<Manga>();
		MalDatabaseAdapter dbAdapter = new MalDatabaseAdapter(getActivity());
		mangas.addAll(dbAdapter.getMangaOverall("onhold"));

		return mangas;
	}
}
